package cn.com.nr.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

import java.util.Date;
import java.util.List;

import cn.com.common.constants.Constants;
import cn.com.common.result.DataResult;
import cn.com.nr.entity.NrDiggingsCalculateEntity;
import cn.com.nr.service.NrDiggingsCalculateService;



/**
 * 矿山吨数/车辆维护
 *
 * @author shaochangyang
 * @email l2l84o7o5@live.com
 * @date 2025-02-08 16:34:40
 */
@Controller
@RequestMapping("/nr/diggingsCalculate")
public class NrDiggingsCalculateController {
    @Autowired
    private NrDiggingsCalculateService nrDiggingsCalculateService;

    @ApiOperation(value = "新增")
    @PostMapping("/add")
    @ResponseBody
    public DataResult add(@RequestBody NrDiggingsCalculateEntity nrDiggingsCalculate){
    	nrDiggingsCalculate.setCreateTime(new Date());
    	nrDiggingsCalculate.setDeleted(Constants.DATA_NOT_DELETED);
    	
    	nrDiggingsCalculateService.save(nrDiggingsCalculate);
        return DataResult.success();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("/delete")
    @ResponseBody
    public DataResult delete(@RequestBody @ApiParam(value = "id集合") List<String> ids){
        nrDiggingsCalculateService.removeByIds(ids);
        return DataResult.success();
    }

    @ApiOperation(value = "更新")
    @PutMapping("/update")
    @ResponseBody
    public DataResult update(@RequestBody NrDiggingsCalculateEntity nrDiggingsCalculate){
        nrDiggingsCalculateService.updateById(nrDiggingsCalculate);
        return DataResult.success();
    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
	@ApiOperation(value = "查询分页数据")
    @PostMapping("/list")
    @ResponseBody
    public DataResult list(@RequestBody NrDiggingsCalculateEntity nrDiggingsCalculate){
        Page page = new Page(nrDiggingsCalculate.getPage(), nrDiggingsCalculate.getLimit());
        LambdaQueryWrapper<NrDiggingsCalculateEntity> queryWrapper = Wrappers.lambdaQuery();
        //查询条件示例
        IPage<NrDiggingsCalculateEntity> iPage = nrDiggingsCalculateService.page(page, queryWrapper);
        return DataResult.success(iPage);
    }

}
